extends NodeState

@export var knife: Knife


var height: float = 0.0
var height_speed: float = 0.0


func _on_process(delta : float) -> void:
	process_air_time(delta)


func _on_next_transitions() -> void:
	pass


func _on_enter() -> void:
	height_speed = knife.knockdown_intensity
	knife.animationPlayer.play(Collectible.ANIMATION_FALL)


func _on_exit() -> void:
	pass




func process_air_time(delta: float):
	knife.sprite.position = Vector2.UP * height

	height += height_speed * delta
	if height < 0.0:
		height = 0.0
		transition_state(Collectible.STATE_GROUNDED)
	else:
		height_speed -= GlobalConstants.GRAVITY * delta
